let express  =  require('express');
let router = express.Router();
let equipmentDao =require('../../model/admin/equipment.js')

//渲染界面
router.get('/',async function (req,res) {
    await res.render('equipment/equipment');   
    })

//获取设备列表

//获取数据 
router.get('/list', async function(req,res){
    let  name = req.query.name;
    let page = req.query.page;
    let length = req.query.limit;
    let start =(page-1)*length;
    let equipmentList  = await equipmentDao.equipmentList(start,length,name);
    let result ={};
    let count =equipmentList[1][0].sum;
    let data =equipmentList[0]; 
    await res.json({code:0,count:count,data:data,msg:''})
})

//删除设备
router.post('/del' ,async function(req,res){
    let id = req.body.id;
    await equipmentDao.delEquipment(id);
    await res.json({status:200,msg:'success'});   
    })
    
module.exports=router;